package com.pzh.logistics.exception;

import com.pzh.logistics.common.ResultVO;
import com.pzh.logistics.util.ResultVOUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthenticatedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.xml.transform.Result;

@RestControllerAdvice
@Slf4j
public class ShiroExceptionHandler {

    @ExceptionHandler(value = AuthorizationException.class)
    @ResponseBody
    public ResultVO handlerException(AuthorizationException e) {
        return ResultVOUtil.error(ResultEnum.UNAUTH.getCode(), ResultEnum.UNAUTH.getMessage());
    }
}